<?php
class Admin_Form_Categories extends Zend_Form
{

    public function init()
    {
        $this->setName("categories");
        $this->setAttrib('enctype','multipart/form-data');
                
        $catName = new Zend_Form_Element_Text('catName');
        $catName->setLabel('Tên categories')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $catName->setAttrib('size', 60);
        
        $modelCategories = new Admin_Model_Categories();
        $categoriesList = $modelCategories->getCategories();
        $parentId = new Zend_Form_Element_Select('parentId');
        $parentId->setLabel('Danh mục cha')->addValidator('alnum')->addValidator('NotEmpty');
        $parentId->addMultiOption('','');
        if(isset($categoriesList)){
            foreach($categoriesList as $key=>$row){
                $parentId->addMultiOption($row->catId,$row->catName);
            }
        }
        
        $ord = new Zend_Form_Element_Text('ord');
        $ord->setLabel('Thứ tự ưu tiên')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $ord->setAttrib('size', 60);

        $status = new Zend_Form_Element_Select('status');
        $status->setLabel('Trạng thái');
        $status->addMultiOption('1','Hoạt động');
        $status->addMultiOption('0','Không hoạt động');
        
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('catId','submitbutton');
        $submit->setAttrib('class',"button medium");
                
        // add elements to form
        $this->addElements(array (
            $catName, $ord, $parentId, $status, $submit
        ));
    }
}

